// https: // iai.sh.cn/problem/760

#include <cstdio>
#include <iostream>
using namespace std;
using LL = long long;

const int MOD = 1000000007ll;

const int SIZE = 2;
struct Matrix {

  LL a[SIZE + 1][SIZE + 1];

  // 初始化， 对角线初始值
  Matrix(LL e = 0) {
    for (int i = 1; i <= SIZE; i++)
      for (int j = 1; j <= SIZE; j++)
        a[i][j] = e * (i == j);
  }

  // 设置单位矩阵
  void set1() {
    for (int i = 1; i <= SIZE; i++)
      for (int j = 1; j <= SIZE; j++)
        a[i][j] = (i == j);
    return;
  }
  // 清零
  void set0() {
    for (int i = 1; i <= SIZE; i++)
      for (int j = 1; j <= SIZE; j++)
        a[i][j] = 0ll; // 长整数0；
    return;
  }

  // 模除
  void modp() {
    for (int i = 1; i <= SIZE; i++)
      for (int j = 1; j <= SIZE; j++)
        a[i][j] %= MOD;
    return;
  }

  void print() {
    for (int i = 1; i <= SIZE; i++) {
      for (int j = 1; j <= SIZE; j++) {
        printf("%lld ", a[i][j]);
      }
      printf("\n");
    }
    printf("\n");
  }
};

Matrix operator*(const Matrix &A, const Matrix &B) {
  Matrix ans(0);
  for (int i = 1; i <= SIZE; i++)
    for (int j = 1; j <= SIZE; j++)
      for (int k = 1; k <= SIZE; k++)
        ans.a[i][j] = (ans.a[i][j] + A.a[i][k] * B.a[k][j]) % MOD;
  //		ans.print();
  //		ans.modp();
  return ans;
}

// 快速幂，注意题意n达到10^18
Matrix ksm(Matrix A, LL b) {
  Matrix ans(1);
  while (b) {
    if (b & 1)
      ans = ans * A;
    A = A * A;
    b >>= 1;
  }

  return ans;
}

int main() {
  LL n;
  scanf("%lld", &n);
  if (n == 1) {
    printf("%lld\n", 3ll);
    return 0;
  } else if (n == 2) {
    printf("%lld\n", 6ll);
    return 0;
  }

  Matrix mTran(0);
  mTran.a[1][1] = -1;
  mTran.a[1][2] = 3;
  mTran.a[2][2] = 2;
  //	mTran.print();

  mTran = ksm(mTran, n - 2ll);
  long long ans = ((mTran.a[1][1] * 6 + mTran.a[1][2] * 4) + MOD) % MOD;

  printf("%lld\n", ans);

  return 0;
}